<%@include file="/page/tag.jsp"%>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title></title>
<!--框架必需start-->
<script type="text/javascript" src="${ctp}/QUI/libs/js/jquery.js"></script>
<%-- <script type="text/javascript" src="${ctp}/js/qui/language/cn.js"></script> --%>
<script type="text/javascript" src="${ctp}/QUI/libs/js/language/cn.js"></script>
<script type="text/javascript" src="${ctp}/QUI/libs/js/framework.js"></script>
<link href="${ctp}/QUI/libs/css/import_basic.css" rel="stylesheet"	type="text/css" />
<link href="${ctp}/QUI/libs/skins/lightBlue/style.css" rel="stylesheet" type="text/css" id="theme" themeColor="deepBlue"/>
<!-- 表单验证start -->
<script src="${ctp}/QUI/libs/js/form/validationRule.js" type="text/javascript"></script>
<script src="${ctp}/QUI/libs/js/form/validation.js" type="text/javascript"></script>
<!-- 表单验证end -->

<!-- 树组件start -->
<script type="text/javascript" src="${ctp}/js/qui/ztree.js"></script>
<link type="text/css" rel="stylesheet" href="${ctp}/css/ztree.css"></link>
<!-- 树组件end -->

<!-- 树形下拉框start -->
<script type="text/javascript" src="${ctp}/QUI/libs/js/form/selectTree.js"></script>
<!-- 树形下拉框end -->

<!-- 日期选择框start -->
<script type="text/javascript" src="${ctp}/QUI/libs/js/form/datePicker/WdatePicker.js"></script>
<!-- 日期选择框end -->

<!--自动提示框start-->
<script type='text/javascript' src='${ctp}/QUI/libs/js/form/suggestion.js'></script>
<!--自动提示框end-->


<!--数据表格start-->
<script src="${ctp}/js/qui/quiGrid.js" type="text/javascript"></script>
<!--数据表格end-->

<!--框架必需end-->

<style>
.del_f{
	margin-left: 10px;
}

#tb_goods{
	width: 100%;
}
</style>
</head>
<body>
	<div style="text-align: center; margin-top:10px; margin-bottom: 10px; font-size: 18px;">生产排单</div>
	<form id="ff" target="frmright" class="" method="post" action="" failAlert="验证未通过">
		<input type="hidden"  name="storageFlowId"  value="<c:out value="${erpStorageFlow.storageFlowId }"/>"/>
		<table class="tableStyle" formMode="line">
			
			<tr>
				<td colspan="2" style="width:350px;">
					客户:<c:out value="${fromQjOrder.crmCustomerInfo.customerName }"/>
				</td>
				<td colspan="1" style="width:350px;">
					付款方式:<c:out value="${fromQjOrder.payType }"/>
				</td>
				<td colspan="2" class="ali03">
					<input id="totalPrice" type="hidden"/>
					订单总价:<span id="show_totalPrice"><c:out value="${fromQjOrder.auditingTotalPrice}"/></span>
				</td>
			</tr>
			
			<tr>
				<td colspan="5" >
					<table class="tableStyle">
						<thead>
							<tr>
								<th>规格</th>
								<th>颜色</th>
								<th>销售单价</th>
								<th>生产单价</th>
								<th>数量</th>
								<th>单位</th>
								<th>是否生产</th>
								<th>操作</th>
							</tr>
						</thead>
						<c:forEach var="it" items="${fromQjOrderDetailList }" varStatus="vs">
							<tr>
								<td>
								 	<div  class="ali02"><c:out value="${it.erpGoodInfo.goodName }"/></div>
								</td>
								<td>
								 	<div  class="ali02"><c:out value="${it.color }"/></div>
								</td>
								<td>
								 	<div id="price_${vs.index }" class="ali02" rel="<c:out value="${it.price }"/>"><c:out value="${it.price }"/></div>
								</td>
								<td>
								 	<div id="price_${vs.index }" class="ali02" rel="<c:out value="${it.scPrice }"/>"><c:out value="${it.scPrice }"/></div>
								</td>
								<td>
								 	<div id="count_${vs.index }"  class="ali02" rel="<c:out value="${it.count }"/>"><c:out value="${it.count }"/></div>
								</td>
								<td>
								 	<div  class="ali02"><c:out value="${it.erpGoodInfo.goodUnit }"/></div>
								</td>
								<td>
									<div id="show_${vs.index }" class="ali02">
										<c:choose>
											<c:when test="${it.isProduce }">是</c:when>
											<c:otherwise>否</c:otherwise>
										</c:choose>
									</div>
								</td>
								<td>
									<div  class="ali02">
										
										<c:choose>
											<c:when test="${it.isProduce }"><span rel="${vs.index }"  class="ctrlBtn img_delete"  ref="<c:out value="${it.qjOrderDetailId }"/>"></span></c:when>
											<c:otherwise><span rel="${vs.index }"  class="ctrlBtn img_ok"  ref="<c:out value="${it.qjOrderDetailId }"/>"></span></c:otherwise>
										</c:choose>
										
									</div>
								</td>
							</tr>
						</c:forEach>
					</table>
				</td>
			</tr>
			
			<tr class="">
				<td style="width:120px;">备注：</td>
				<td colspan="4">
					<div><c:out value="${fromQjOrder.remark }"/></div>
					<div id="fromMore">
						
					</div>
				</td>
			</tr>
			
			<tr class="">
				<td colspan="5">
					<button type="button" onclick="submitF(-1)">回退上一节点</button>
					<button type="button" onclick="submitF(1)">流转下一节点</button>
				</td>
			</tr>
		</table>
	</form>
	<script>
		function closeWin() {
			top.Dialog.close();
		}
		
		function initComplete(){
		}
		
		var totalPrice =0.0;
		var detailArr = new Array();
		$(function(){
			$(".ctrlBtn").click(function(){
				var id = $(this).attr("rel");
				var delId = $(this).attr("ref");
				if($(this).hasClass("img_ok")){
					$(this).removeClass("img_ok");
					$(this).addClass("img_delete");
					$("#show_"+id).html("是");
					totalPrice += parseInt($("#price_"+id).attr("rel")) * parseInt($("#count_"+id).attr("rel"));
					detailArr.push(delId);
				} else {
					$(this).removeClass("img_delete");
					$(this).addClass("img_ok")
					$("#show_"+id).html("否");
					totalPrice -= parseInt($("#price_"+id).attr("rel")) * parseInt($("#count_"+id).attr("rel"));
					detailArr.removeArr(delId);
				}
				
				$("#totalPrice").val(totalPrice);
				$("#show_totalPrice").html(totalPrice);
			});
			
		});
		
		 Array.prototype.removeArr = function(e){
			for(var i in this){
				if(this[i] == e){
					this.splice(i, 1);  
				}
			}
		}
		 
		function submitF(sta){
			if(detailArr.length ==0 && sta != -1){
				top.Dialog.alert("请选择生产的产品", null, null, null, 2);
				return false;
			}
			
			$.ajax({
				url:"${ctp}/quanjin/scpd.do?processId=${processId}&orderId=${orderId}&taskId=${taskId}&oid=${fromQjOrder.qjOrderId}&ids="+detailArr.join(',')+"&status="+sta,
				success:function(data){
					var popBox = new top.Dialog({
						Width:300,
       					Height:110
					});
					if (data.result) {
						popBox.Title = data.msg;
						popBox.InnerHtml = '<table height="100%" border="0" align="center" cellpadding="10" cellspacing="0">\
									<tr><td align="right"><input type="button" id="Icon_' + this.ID + '" class="icon_alert" align="absmiddle"></td>\
										<td align="left" id="Message_' + this.ID + '" style="font-size:' + (popBox.defaultFontSize) + 'px;font-family:' + (popBox.defaultFontFamily) + '">' + data.msg + '</td></tr>\
								</table>';
						popBox.ShowCloseButton = false;
						popBox.ShowCancelButton = false;
						
						popBox.OKEvent = function() {
							popBox.close();
							top.frmright.reflushList();
							top.Dialog.close();
						};
						popBox.show();
						popBox.okButton.parentNode.style.textAlign = "center";
					} else {
						top.Dialog.alert(data.msg, null, null, null, 2);
					};
				}
			});
		}
		
	</script>
</body>
</html>

